<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Formatting text paragraphs</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets V1.76.0"><link rel="home" href="index.html" title="JpGraph Manual"><link rel="up" href="ch08.html" title="Chapter 8. Text and font handling"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Formatting text paragraphs</th></tr><tr><td width="20%" align="left"> </td><th width="60%" align="center">Chapter 8. Text and font handling</th><td width="20%" align="right"> </td></tr></table><hr></div><div class="sect1" title="Formatting text paragraphs"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="id2498877"></a>Formatting text paragraphs</h2></div></div></div>
            
            <p>The text rendering engine within the library offers some basic text paragraph
                formatting.</p>
            <p>
                </p><div class="itemizedlist"><ul class="itemizedlist" type="disc"><li class="listitem">
                        <p>It is possible to use multi line text combined as a paragraph</p>
                    </li><li class="listitem">
                        <p>It is possible to adjust the text alignment within the paragraph to be
                            left, right or center adjusted. This works in the same way as you would
                            expect in a word-processor.</p>
                    </li><li class="listitem">
                        <p>If enabled the text rendering will support automatic line breaks at a
                            certain column. The line breaks are intelligent not to break words in
                            the middle.</p>
                    </li></ul></div><p>
            </p>
            <p>All text handling is centralized to the class <code class="code">Text</code> (defined in file
                    <code class="filename">jpgraph_text.inc.php</code>) which is used both to add arbitrary
                text to the graph as well as internally within the library to manipulate text on
                labels and titles. All such texts are an instance of the Text class.</p>
            <p>The paragraph alignment is controlled by the method
                    <code class="code">Text::SetParagraphAlign($aAlignment)</code>. The argument is a text string
                that should be one of <code class="code">'left'</code>, <code class="code">'right'</code> or
                    <code class="code">'center'</code>. </p>
            <p>
                </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                    <p>Unfortunately the library does not support an "even" paragraph alignment
                        which in word processors adjust the kerning between individual characters to
                        make the text have even left and right sides. Implementing this would
                        require a much higher complexity than can be motivated for the type of text
                        needed in a graph library.</p>
                </div><p>
            </p>
            <p>In the <a class="xref" href="ch08s05.html#fig.textpalignex1" title="Figure 8.5. The different types of paragraph alignments (textpalignex1.php)">Figure 8.5. The different types of paragraph alignments <code class="uri"><a class="uri" href="example_src/textpalignex1.html" target="_top">(<code class="filename">textpalignex1.php</code>)</a></code> </a> the same text paragraph is rendered with the
                possible paragraph alignments.</p>
            <p>
                </p><div class="figure"><a name="fig.textpalignex1"></a><p class="title"><b>Figure 8.5. The different types of paragraph alignments <code class="uri"><a class="uri" href="example_src/textpalignex1.html" target="_top">(<code class="filename">textpalignex1.php</code>)</a></code> </b></p><div class="figure-contents">  <span class="inlinemediaobject"><img src="images/textpalignex1.png" alt="The different types of paragraph alignments (textpalignex1.php)"></span> </div></div><p><br class="figure-break">
            </p>
            <p>Inserting a newline character "\n" in text will cause the text line to break and
                start on the next row. Note that the newline must be surrounded with double-quotes
                and not single quotes.</p>
            <p>
                </p><div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3>
                    <p>Bitmap fonts that are rotated, i.e. vertical, does not support automatic
                        line breaking. If line breaking is needed with vertical text then one of the
                        TTF fonts muts be used.</p>
                </div><p>
            </p>
        </div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"> </td><td width="20%" align="center"><a accesskey="u" href="ch08.html">Up</a></td><td width="40%" align="right"> </td></tr><tr><td width="40%" align="left" valign="top"> </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> </td></tr></table></div></body></html>
